{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d9c9144b",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Author : jiang\n",
    "# week 07\n",
    "\n",
    "#回顾\n",
    "names_str = \"Alex,marry,jack\"\n",
    "names_list = [\"Alex\",\"marry\",\"jack\"]\n",
    "\n",
    "#print(names_str[0:4]) # 字符串，我无法确定名字长度？用切片的复杂操作\n",
    "#print(names_list[0]) # 用index索引的操作\n",
    "\n",
    "# 本周重点：list的方法\n",
    "# 思考：对于一个序列数据，我们可以做什么操作？\n",
    "# 1.取值：切片\n",
    "# 2.增加/新增数据，stu_网新1班 = [...]\n",
    "\n",
    "\n",
    "names = [\"mike\",\"marry\",\"jan\",\"jack\"]\n",
    "# 2.1 append()圆括号的内容是 对象（比较大的一个范围，python中一切皆是对象)\n",
    "#      append()新增在末尾\n",
    "\n",
    "names.append(\"zhichao\")\n",
    "names.append(\"youge\")\n",
    "print(names)\n",
    "\n",
    "#2.2 insert() 指定位置新增数据\n",
    "names.insert(2,\"zhichao\")\n",
    "print(names)\n",
    "\n",
    "# 3.删除:\n",
    "# 3.1 remove()的操作应该先做查询，判断元素value是否存在？\n",
    "names.remove(\"youge\")\n",
    "print (names)\n",
    "\n",
    "# * 先做查询： seq的一般方法（通用方法）\n",
    "# print (\"lihua\" in names) #False/True\n",
    "# username = input(\"names:\")\n",
    "# if username in names:\n",
    "    # 删除该用户\n",
    " #   names.remove(username)\n",
    "#else:\n",
    " #   names.append(username)\n",
    "#print(names)\n",
    "#names.remove(\"lihua\")\n",
    "#print (names)\n",
    "\n",
    "# 3.2 pop() 在使用pop（）之前，要先了解list的长度？清楚删除的索引位置\n",
    "# 要先了解list的长度？seq 的一般方法 len()\n",
    "print(len(names))\n",
    "print(names)\n",
    "names.pop(2)\n",
    "print(names)\n",
    "# 清楚删除的索引位置？\n",
    "#print(names.(index(\"jan\"))\n",
    "# 案例： 删除一些具有特征的索引值\n",
    "#for i in range(0,len(names)-1,2):\n",
    "#    names.pop(i)\n",
    "#print(names)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
